package com.dt.utils.pdf.controller;

import com.dt.utils.pdf.domain.ViewPDF;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/")
public class PrintPdfController {

    @GetMapping("printPdf")
    public ModelAndView printPdf(){

        List<Map<String,String>> products = new ArrayList<>();
        Map<String,String> map = new HashMap<>(  );
        map.put( "名称","name" );
        map.put( "年龄","1" );
        products.add(map);
        Map<String,String> map2 = new HashMap<>(  );
        map2.put( "名称","name2222" );
        map2.put( "年龄","2222" );
        products.add(map2);

        Map<String, Object> model = new HashMap<>();
        model.put("sheet", products);
        return new ModelAndView(new ViewPDF(), model);
    }
}
